package main

import "fmt"

func main() {
	var myLen int
	var inputs []int
	var needSum int
	n, _ := fmt.Scan(&myLen)
	if n == 0 {
		fmt.Println(-1, -1)
		return
	} else {
		for i := 0; i < myLen; i++ {
			var input int
			n2, _ := fmt.Scan(&input)
			if n2 != 0 && input > 0 {
				inputs = append(inputs, input)
			}
		}
	}
	n3, _ := fmt.Scan(&needSum)
	if n3 == 0 {
		fmt.Println(-1, -1)
		return
	}

	haveResult := false

	for i := 0; i < myLen-1; i++ {
		for j := i; j < myLen; j++ {
			if inputs[i]+inputs[j] == needSum {
				haveResult = true
				fmt.Println(i, j)
				return
			}
		}
	}

	if haveResult == false {
		fmt.Println(-1, -1)
	}

}

func binarySearch(checkSlice []int, findVal int) int {
	pos := -1
	left, right := 0, len(checkSlice)
Loop:
	for {
		if left >= right {
			break Loop
		}
		mid := (left + right) / 2
		switch true {
		case checkSlice[mid] < findVal:
			left = mid
		case checkSlice[mid] == findVal:
			pos = mid
			break Loop
		case checkSlice[mid] > findVal:
			right = mid
		}
	}
	return pos
}
